/*
 * @Author: 专送Pro
 * @Date: 2019-08-23 13:17:18
 * @LastEditors  : wuzhen
 * @LastEditTime : 2020-01-04 16:10:35
 * @Description: 新增表单配置文件
 */
export default {
  data() {
    return {};
  },
  computed: {
    formProps() {
      return [
        {
          forms: [
            {
              label: "用户账号",
              type: "text",
              key: "account",
              span: 22,
              placeholder: "请输入用户账号",
              maxlength: 20,
              rules: {
                required: true,
                trigger: "blur",
                validator: (rule, value, callback) => {
                  if (!/^[a-zA-Z1-10]{2,20}$/.test(value)) {
                    return callback(new Error("只支持2-20个英文字母！"));
                  } else if (!value) {
                    return callback(new Error("请输入用户账号,(长度:2-20)！"));
                  } else {
                    callback();
                  }
                }
              }
            },
            {
              label: "用户名称",
              type: "text",
              key: "membername",
              span: 22,
              placeholder: "请输入用户名称",
              rules: {
                required: true,
                trigger: "blur",
                validator: (rule, value, callback) => {
                  if (!/^[\u4E00-\u9FA5]{1,10}$/.test(value)) {
                    return callback(new Error("只支持1-10个汉字！"));
                  } else if (!value) {
                    return callback(new Error("用户名称不能为空！"));
                  } else {
                    callback();
                  }
                }
              }
            }
          ]
        }
      ];
    },
    formPropsRole() {
      return [
        {
          forms: [
            {
              label: "所属角色",
              key: "role",
              slot: true,
              span: 24
            }
          ]
        }
      ];
    }
  }
};
